<?php
namespace app\house\model;
use app\BaseModel;
use think\facade\Db;



class AdminAppointment extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_house_appointment';


    /**
     * @var array
     * 查询器
     */
    protected $append = [
        'staff_name_text',
        'house_text'
    ];

    /**
     * @param $value
     * @param $data
     * @return mixed
     * 员工
     */
    public function getStaffNameTextAttr($value,$data){
       $name = Db::name('longbing_card_user_info')->where(['fans_id' => $data['to_uid'], 'uniacid' => $data['uniacid'], 'is_staff' => 1])->value('name');
        return !empty($name)?$name:'员工不存在';
    }

    /**
     * @param $value
     * @param $data
     * 获取房源
     */
    public function getHouseTextAttr($value,$data){
        $house = Db::name('longbing_card_house')->where(['status'=>1,'id'=>$data['house_id']])->value('title');
        return !empty($house)?$house:'房源已被禁用或者删除';
    }
    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 房产预约列表
     */
    public function appList($dis,$page=10){
        $data = $this->where($dis)->status(-1)->order('id desc')->paginate($page)->toArray();
        return $data;
    }



}